#include<bits/stdc++.h>
using namespace std;
int n,k;
int d[1000011];
int dep[1000011];
vector<int> v[1000011];
int ans;
void DFS(int p)
{
	dep[p] = 1;
	for(auto i:v[p])
	{
		DFS(i);
		if(dep[i] == k)
			ans += (p != 1);
		else
			dep[p] = max(dep[p],dep[i] + 1); 
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("lost.in","r",stdin);
	freopen("lost.out","w",stdout);
	cin >> n >> k;
	cin >> d[1];
	if(d[1] != 1)
		ans++,d[1] = 1;
	for(int i = 2;i <= n;i++)
		cin >> d[i],v[d[i]].push_back(i);
	DFS(1);
	cout << ans;
	return 0;
}
